-
Notifications
You must be signed in to change notification settings - Fork 797
Add Custom Shader Uniforms for Cursor Effects #6912
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Add Custom Shader Uniforms for Cursor Effects #6912
Conversation
- Changed Uniforms struct in custom.zig to incorporate cursor data - Added iCurrentCursor, iPreviousCursor, and iTimeCursorChange to the shadertoy_prefix.glsl
Holy crap that is awesome. I was meh on cursor trails before but I def want this. |
if (self.gl_state) |*gl_state| { | ||
if (gl_state.custom) |*custom_state| { | ||
custom_state.addCursor(self.size, screen.cursor, cursor_style, render.glyph); | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looking at other parts of the code, I wonder if we should use the "deferred" pattern as used by SetFontSize
, SetScreenSize
, etc. The custom state seems to be more commonly modified there.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll look into it and see how I can adapt it.
// Additionally, the y-position is adjusted to account for the inverted Y-axis | ||
// in the window coordinate system used by gl_FragCoord, where the origin is at the bottom-left. | ||
// The offset from the glyph is also added to position the cursor correctly. | ||
const current_x: f32 = @as(f32, @floatFromInt(cursor.x * size.cell.width + size.padding.left)) + @as(f32, @floatFromInt(glyph.offset_x)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I might be misreading this, but since the two floats added together both came from integers, why not just:
const current_x: f32 = @as(f32, @floatFromInt(cursor.x * size.cell.width + size.padding.left)) + @as(f32, @floatFromInt(glyph.offset_x)); | |
const current_x: f32 = @floatFromInt(cursor.x * size.cell.width + size.padding.left + glyph.offset_x); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I can't add glyph.offset directly because it's an i32, while all the other variables are u32.
Fix comment space Co-authored-by: Kat <[email protected]>
I tried to run a couple of your shaders (blaze and smear) but they result in nothing being drawn. I've verified other [non-cursor] shaders work. I'm still trying to debug why that is but just wanted to let you know in case you knew. Thanks 😄 I just want something working here so I can better iterate on this PR. EDIT: Ah, I see they're not really setup to be Ghostty shaders directly yet since they don't sample the screen. Looking at it. |
This comment has been minimized.
This comment has been minimized.
This requires some modifications so it works with Metal (something I plan to do) and some good example shaders (which were provided in the discussion). It'll be merged eventually... |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
It should be noted that PRs are not spaces for tech support. They are for reviewers to review code. Please leave your issues in the original discussion (#6901) going forwards. |
Hi,
As requested, this is a pull request for discussion #6901. It adds cursor position data to the uniforms for custom shaders, enabling more dynamic and interactive effects.
Let me know if any adjustments are needed. Thanks!
blaze_trail.mp4